home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 2000 #1 / Amiga Plus CD - 2000 - No. 1.iso / Tools / Dev / Meshwriter / MeshWriterTest / modules / pawn.c < prev    next >
Encoding:
C/C++ Source or Header  |  1999-12-03  |  3.1 KB  |  98 lines

  1. /*
  2. **      $VER: pawn.c 1.00 (20.3.1999)
  3. **
  4. **      Creation date     : 20.3.1999
  5. **
  6. **      Description       :
  7. **         MeshWriter testprogram shape module.
  8. **
  9. **
  10. **      Written by Stephan Bielmann
  11. **
  12. */
  13.  
  14. /*************************** Includes *******************************/
  15.  
  16. #ifndef WITHMWLLIB
  17. #include "//meshlib.h"
  18. #else
  19. #include <meshwriter/meshwriter.h>
  20. #include <pragma/meshwriter_lib.h>
  21. #endif
  22.  
  23. /**************************** Defines *******************************/
  24.  
  25. #define PI            3.14159265359
  26. #define ROTSTEPS      9
  27.  
  28. /*********************** Type definitions ***************************/
  29.  
  30. /********************** Private functions ***************************/
  31.  
  32. /********************** Public functions ****************************/
  33.  
  34. /********************************************************************\
  35. *                                                                    *
  36. * Name         : pawn                                                *
  37. *                                                                    *
  38. * Description  : Draws a pawn with the help of the rotation function.*
  39. *                                                                    *
  40. * Arguments    : mesh    IN  : An initialized mesh handle.           *
  41. *                                                                    *
  42. * Comment      :                                                     *
  43. *                                                                    *
  44. \********************************************************************/
  45. void pawn(ULONG mesh) {
  46.   TOCLVertex v1,v2,vr;
  47.   TOCLColor color;
  48.   ULONG white,i;
  49.   TOCLFloat apawn[] = {40,40,39,37,38.5,39,38,37,36,34.5,31,28,26,23.6,22,20,18,16,14.5,
  50.                        13,11.5,11.2,11.2,11.5,13.6,15.5,22,28.7,28.5,22,16,16.8,20,22.7,
  51.                        24.5,25.3,25.5,25,24,22,18.5,13.5,0};
  52.  
  53.   MWLMeshMaterialAdd(mesh,&white);
  54.   color.r=255,color.g=255,color.b=255;
  55.   MWLMeshMaterialNameSet(mesh,white,"White");
  56.   MWLMeshMaterialDiffuseColorSet(mesh,white,&color);
  57.   MWLMeshMaterialShininessSet(mesh,white,0);
  58.   MWLMeshMaterialTransparencySet(mesh,white,0);
  59.  
  60.   MWLMeshNameSet(mesh,"Pawn");
  61.  
  62.   // the ground, a circle
  63.   v1.x=40,v1.y=0,v1.z=0;
  64.   vr.x=0,vr.y=0;
  65.   MWLMeshPolygonAdd(mesh,white);
  66.   for(vr.z=0;vr.z<2*PI;vr.z+=PI/ROTSTEPS) {
  67.     MWLMeshPolygonVertexAdd(mesh,&v1);
  68.     MWLMeshRotationChange(mesh,&vr,CTMSET);
  69.   }
  70.  
  71.   // the body, with the help of the apawn radius array
  72.   v1.y=0;
  73.   v2.y=0;
  74.   vr.x=0,vr.y=0;
  75.   for(i=0;i<43-1;i++) {
  76.     MWLMeshPolygonAdd(mesh,white);
  77.     v2.x=apawn[i+1],v2.z=2*(i+1);
  78.     MWLMeshPolygonVertexAdd(mesh,&v2);
  79.     v1.x=apawn[i],v1.z=(2*i);
  80.     MWLMeshPolygonVertexAdd(mesh,&v1);
  81.  
  82.     for(vr.z=0;vr.z<2*PI;vr.z+=PI/ROTSTEPS) {
  83.       MWLMeshRotationChange(mesh,&vr,CTMSET);
  84.  
  85.       v1.x=apawn[i],v1.z=2*i;
  86.       MWLMeshPolygonVertexAdd(mesh,&v1);
  87.       v2.x=apawn[i+1],v2.z=2*(i+1);
  88.       MWLMeshPolygonVertexAdd(mesh,&v2);
  89.  
  90.       MWLMeshPolygonAdd(mesh,white);
  91.       MWLMeshPolygonVertexAdd(mesh,&v2);
  92.       MWLMeshPolygonVertexAdd(mesh,&v1);
  93.     }
  94.   }
  95. }
  96.  
  97. /************************* End of file ******************************/
  98.